package com.fenghuajueli.libbasecoreui.ui;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.blankj.utilcode.util.ToastUtils;
import com.fenghuajueli.libbasecoreui.R;
import com.fenghuajueli.libbasecoreui.mvp.BaseActivity;
import com.fenghuajueli.libbasecoreui.utils.MyStatusBarUtils;

public class FeedBackActivity extends BaseActivity {

    EditText etInputContent;
    Button btnUpload;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feed_back);
        etInputContent = findViewById(R.id.etInputContent);
        btnUpload = findViewById(R.id.btnUpload);
        btnUpload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (etInputContent.getText().toString().trim().isEmpty()) {
                    ToastUtils.showShort("请输入反馈内容");
                    return;
                }
                showLoadingDialog();
                etInputContent.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ToastUtils.showShort("提交成功");
                        hideLoadingDialog();
                        finish();
                    }
                }, 1000);
            }
        });
        btnUpload.setEnabled(false);
        etInputContent.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (s.length() > 0) {
                    btnUpload.setEnabled(true);
                    btnUpload.setBackgroundResource(R.drawable.shape_btn_can_use_bg);
                } else {
                    btnUpload.setEnabled(false);
                    btnUpload.setBackgroundResource(R.drawable.shape_btn_not_use_bg);
                }
            }
        });
    }
}
